from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
import pandas as pd

# 加载数据集
iris = load_iris()
x_train, x_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=33)
# print(x_train.shape)
# print(x_test.shape)
# print(y_train.shape)
# print(y_test.shape)

# 本地加载数据集
# df = pd.read_csv("iris.csv")
# y = df["outocme"]
# x = df.iloc[:, :-1]
# x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2, random_state=33)
# print(x_train.shape)
# print(x_test.shape)
# print(y_train.shape)
# print(y_test.shape)


# 随机数种子
# x_train1, x_test1, y_train1, y_test1 = train_test_split(iris.data, iris.target, random_state=6)
# x_train2, x_test2, y_train2, y_test2 = train_test_split(iris.data, iris.target, random_state=6)
# print("如果随机数种子不一致：\n", x_train == x_train1)
# print("如果随机数种子一致：\n", x_train1 == x_train2)